<template>
  <main class="supplier-system">
    <div class="min-pc-width system">
      <p class="header"><span>第1页</span></p>
      <!-- <a-form :form="form" @submit="handleSubmit"> -->
      <a-form :form="form" @submit="handleSubmit">
        <a-form-item label="成果名称" class="form-item mt60">
          <a-input v-decorator="['cgmch',{ initialValue: formData.cgmch || '' ,  rules: [{ required: true, message: '成果名称不能为空!' }]}]" placeholder="成果名称" autocomplete="off" />
        </a-form-item>
        <a-form-item label="完成单位" class="form-item">
          <a-input v-decorator="['wcdw',{ initialValue: formData.wcdw || '' ,  rules: [{ required: true, message: '完成单位不能为空!' }]}]" placeholder="完成单位" autocomplete="off" />
        </a-form-item>
        <a-form-item label="申请单位" class="form-item">
          <a-input v-decorator="['sqdw',{ initialValue: formData.sqdw || '' ,  rules: [{ required: true, message: '申请单位不能为空!' }]}]" placeholder="申请单位" autocomplete="off" />
        </a-form-item>
        <a-form-item label="申请日期" class="form-item">
          <a-date-picker  v-decorator="['sqriqi',{ initialValue: formData.sqriqi || '' ,  rules: [{ required: true, message: '申请日期不能为空!' }]}]" style="width: 100%" />
        </a-form-item>
        <a-form-item label="组织评价单位" class="form-item">
          <a-input disabled v-model="zzdw" placeholder="组织评价单位" />
        </a-form-item>
        <div class="supplier-footer">
          <a-button @click="goBack" class="s-btn">
            返回
          </a-button>
          <a-button html-type="submit"  class="s-btn"  @click="save">
          <!-- <a-button html-type="submit" class="s-btn"> -->
            保存
          </a-button>
          <a-button @click="resetForm" class="s-btn">
            重填
          </a-button>
          <a-button  html-type="submit"  type="primary" @click="goNext" class="s-btn">
            继续
          </a-button>
        </div>
    </a-form>
    </div>
  </main>
</template>
<script>
export default {
  data () {
    return {
      currentIndex: 0,
      form: this.$form.createForm(this),
      type: 0,
      zzdw: '上海市安装行业协会',
      formId: '',
      formData: ''
    }
  },
  components: {
  },
  computed: {
  },
  created () {
    if (this.$route.query.id) {
      this.formId = this.$route.query.id
      this.getKJCXFormDataById()
    }
  },
  methods: {
    goBack () {
      this.$router.go(-1)
    },
    goNext () {
      this.type = 1
    },
    save () {
      this.type = 0
    },
    memberStepForm (values) {
      this.$http.persistCgjdForm(Object.assign(values, {
        id: this.formId
      })).then(res => {
        this.formId = res.data.id
        if (this.type == 1) {
          this.$router.push({ path: `/innovation/supplier/2?id=${res.data.id}` })
        }
      })
    },
    getKJCXFormDataById () {
      this.$http.queryCgjdForm({ id: this.formId }).then(res => {
        Object.keys(v => {
          this.$set(this.formData, v, res.data[v])
        })
        this.formData = res.data
      })
    },
    handleSubmit (e) {
      let _this = this
      e.preventDefault()
      this.form.validateFields((err, values) => {
        if (!err) {
          _this.memberStepForm(values)
        }
      })
    },
    resetForm () {
      this.form.resetFields()
    }
  }
}
</script>
<style lang="scss">
</style>
